home *** CD-ROM | disk | FTP | other *** search
- Path: gate.compart.fi!usenet
- From: joonas.kervinen@pcb.compart.fi (joonas kervinen)
- Newsgroups: comp.lang.c
- Subject: How to detect if a number has fractions
- Date: Fri, 12 Apr 1996 20:27:13 GMT
- Organization: Compart Internet, Helsinki, Finland
- Message-ID: <4klb63$h4e@gate.compart.fi>
- NNTP-Posting-Host: spider.compart.fi
- X-Newsreader: Forte Free Agent 1.0.82
-
- Here's a small detail that's bugging me: How do I detect in Borland C
- (BCC4.5 or 5.0) whether a double value has fractions. And I mean
- quickly, not using time consuming floating point functions (floor()
- ceil() etc.).
- I got many replies using something like:
- if (doublenum==(double)(int)doublenum)
- puts("no fractions");
-
- But unfortunately it does work for numbers below (about) 32000. Using
- long helps a little but not all. So the question remains.
-
- Another addition: I'd also like to know how many faction (like 3 in
- 23.234) a double contains.
-
- Please answer via e-mail.
-
-